#include "ROPropertyUpdater.h"
#include "ROSyncProperty.h"
#include "QQuickROData.h"
ROPropertyUpdater::ROPropertyUpdater(QObject *parent):QObject(parent)
{
}

ROPropertyUpdater::SafePolicy ROPropertyUpdater::safePolicy() const
{
    return m_safePolicy;
}

void ROPropertyUpdater::setSafePolicy(SafePolicy newSafePolicy)
{
    if (m_safePolicy == newSafePolicy)
        return;
    m_safePolicy = newSafePolicy;
    emit safePolicyChanged();
}

void ROPropertyUpdater::updateProperty(ROSyncProperty *target, const QStringList &props)
{
    if(!m_enabled)
    {
        return;
    }

    if(target->role() == ROSyncProperty::Host)
    {
        target->updateProperties(props,m_safePolicy == SafePolicy::Safe);
    }
}

bool ROPropertyUpdater::enabled() const
{
    return m_enabled;
}

void ROPropertyUpdater::setEnabled(bool newEnabled)
{
    if (m_enabled == newEnabled)
        return;
    m_enabled = newEnabled;
    emit enabledChanged();
}
